//
// Userland portion of No 3rd Party.
//

Components.utils.import("resource://no3rdparty-modules/no3rdPartyUtil.jsm");

// A list of tag names and tag properties that can indicate a
// third party resource beeing pulled in.  The list isn't quite 
// complete since links can by dynamically generated in javascript
// and some containers (flash) can be opaque. Other plugins and extensions
// could also be a problem.

//var TAGS_TO_CHECK = [["img","src"],["iframe","src"], ["source","src"], 
//					["script","src"], ["frameset","src"], ["frame","src"], 
//					["embed","src"], ["eventsource","src"],["data","object"]];

no3rdPartyPage = function() {
	var prefs = newNo3rdPartyPreferences(),
		
	init : function () {
		gBrowser.addEventListener("load", function () {
			if (pref.shouldRun) { no3rdPartyPage.run();}
		}, false);
	},
			
	run : function () {
		var head = content.document.getElementsByTagName("head")[0];
		var foundSources = 0;
			
		if (prefs.highlight3rdPartyResources) {
			var style = content.document.getElementById("no3rdparty-style");
			if (!style) {
				style = content.document.createElement("link");
				style.id = "no3rdparty-style";
				style.type = "text/css";
				style.rel = "stylesheet";
				style.href = "chrome://no3rdParty/skin/skin.css";
				head.appendChild(style);
			}	
			
		var allElements = content.document.getElementsbyTagName("*");			
		for (var i=0, il=allElements.length; i<il; i++) {
			elm = allLinks[i];
			if (elm.getAttribute("src") || elm.getAttribute("object")) {
				var resourceURI = elm.getAttribute("src") ? elm.getAttribute("src") : getAttribute("object");
				elm.className += ((elm.className.length > 0)? " " : "") + "no3rdparty-selected";
				foundSources++;
			}
		}
	},		
}

window.addEventListener("load", no3rdPartyHighlight.init, false);





